//
// Created by ljy on 10/25/21.
//
#ifndef _LINUX_FS_H
#define _LINUX_FS_H
#include <linux/kdev_t.h>
#include <linux/mmzone.h>
#include <linux/list.h>

struct address_space {
    struct list_head	clean_pages;	/* list of clean pages */
    struct list_head	dirty_pages;	/* list of dirty pages */
    struct list_head	locked_pages;	/* list of locked pages */
    unsigned long		nrpages;	/* number of total pages */
    struct address_space_operations *a_ops;	/* methods */
    struct inode		*host;		/* owner: inode, block_device */
    struct vm_area_struct	*i_mmap;	/* list of private mappings */
    struct vm_area_struct	*i_mmap_shared; /* list of shared mappings */
    //spinlock_t		i_shared_lock;  /* and spinlock protecting it */
    int			gfp_mask;	/* how to allocate the pages */
};

struct buffer_head {
    /* First cache line: */
    struct buffer_head *b_next;	/* Hash queue list */
    unsigned long b_blocknr;	/* block number */
    unsigned short b_size;		/* block size */
    unsigned short b_list;		/* List that this buffer appears */
    kdev_t b_dev;			/* device (B_FREE = free) */

    atomic_t b_count;		/* users using this block */
    kdev_t b_rdev;			/* Real device */
    unsigned long b_state;		/* buffer state bitmap (see above) */
    unsigned long b_flushtime;	/* Time when (dirty) buffer should be written */

    struct buffer_head *b_next_free;/* lru/free list linkage */
    struct buffer_head *b_prev_free;/* doubly linked list of buffers */
    struct buffer_head *b_this_page;/* circular list of buffers in one page */
    struct buffer_head *b_reqnext;	/* request queue */

    struct buffer_head **b_pprev;	/* doubly linked list of hash-queue */
    char * b_data;			/* pointer to data block */
    struct page *b_page;		/* the page this bh is mapped to */
    void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */
    void *b_private;		/* reserved for b_end_io */

    unsigned long b_rsector;	/* Real buffer location on disk */
//    wait_queue_head_t b_wait;

    struct list_head     b_inode_buffers;	/* doubly linked list of inode dirty buffers */
};
#endif
